package com.ruoyi.web.controller.vis;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.SysNotice;
import com.ruoyi.system.vis.domain.VisCase;
import com.ruoyi.system.vis.domain.VisRegForm;
import com.ruoyi.system.vis.domain.reg.SysPatient;
import com.ruoyi.system.vis.service.VisCaseService;
import com.ruoyi.system.vis.service.VisRegFormService;
import com.ruoyi.system.vis.service.reg.SysPatientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/vis/regform")
public class RegFormController  extends BaseController {
    @Autowired
    private VisCaseService visCaseService;
    @Autowired
    private VisRegFormService visRegFormService;
    @Autowired
    private SysPatientService sysPatientService;
    //查询所有待就诊患者信息
    @GetMapping("/waite")
    public AjaxResult waite(){
        List<VisRegForm> visRegForms = visRegFormService.selectWaite();
        if (visRegForms==null){
            return AjaxResult.error("暂无数据");
        }
        return AjaxResult.success(visRegForms);

    }
    //    查询患者信息
   @PostMapping("/show")
    public AjaxResult list(@RequestBody String patientName){

        SysPatient sysPatient = sysPatientService.selectPatientByName(patientName);

       System.out.println(sysPatient);
       return AjaxResult.success(sysPatient);

    }
    //添加病例
    @PostMapping("/add")
    public AjaxResult add(@Validated @RequestBody VisCase visCase)
    {
        visCase.setDoctorName(getUsername());
        return toAjax(visCaseService.addCase(visCase));
    }

}
